<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>选择位置</title>
<style type="text/css">
*{
    margin:0px;
    padding:0px;
}
body, button, input, select, textarea {
    font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
}

</style>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=<?=$da['qqmapkey']?>"></script>
<script src="js/jquery.js"></script>
<script src="js/base64-min.js"></script>
<script>

var callback = '<?=$callback?>'; //回调函数
var init = function() {
    var center = new qq.maps.LatLng(<?=$location_x?>,<?=$location_y?>);
    map = new qq.maps.Map(document.getElementById('container'),{
        center: center,
        zoom: <?=$scale?>
    });
	
	marker = new qq.maps.Marker({
        position: center,
        map: map,
		draggable:true,
		title:'点地图确定位置'
    });
    
	//点击地图切换位置
	qq.maps.event.addListener(map, 'click', function(evt) {
		marker.setPosition(evt.latLng);
    });
	
	return;
	infoWin = new qq.maps.InfoWindow({
        map: map
    });
    infoWin.open();
    infoWin.setContent('位置：');
    infoWin.setPosition(map.getCenter());
}
function qudong(){
	var as = marker.getPosition();
	var x 	= as.getLat();
	var y 	= as.getLng();
	var zoom = map.getZoom();
	var a = {x:x,y:y,zoom:zoom};
	if(callback!=''){
		try{
			parent[callback](a);
			parent.js.tanclose('winiframe');
		}catch(e){}
	}
}
var citylocation = false;
function dingwei(){
	var key = prompt('请输入格式(地址 城市)如：鼓浪屿 厦门');
	if(key){
		$.ajax({
			url:'api.php?m=kaoqin&a=suggestion',
			data:{key:jm.base64encode(key)},
			dataType:'json',
			success:function(ret){
				if(ret.status==0){
					var res = ret.data[0];
					var center = new qq.maps.LatLng(res.location.lat,res.location.lng);
					map.setCenter(center);
					marker.setPosition(center);
					showinfoWin(res.title+'<br>'+res.address);
				}else{
					alert(ret.message);
				}
			}
		});
	}
}
var infoWin = false;
function showinfoWin(msg){
	if(!infoWin){
		infoWin = new qq.maps.InfoWindow({
			map: map
		});
		infoWin.open();
	}
    infoWin.setContent(msg);
    infoWin.setPosition(map.getCenter());
}
</script>
</head>
<body onload="init()">
<div style="position:absolute;top:0px;left:40%;z-index:99;padding:5px 20px; background-color:white"><button style="background:#1389D3;color:white;border:none;padding:5px 8px;cursor:pointer" onclick="qudong()">确定</button>&nbsp;点地图确定位置，<a href="javascript:;" onclick="dingwei()">[定位搜索]</a></div>
<div style="width:100%;height:100%" id="container"></div>
</body>
</html>
